from rest_framework import serializers

from basic_info.models import WarehouseModel


class WarehouseSerializer(serializers.ModelSerializer):
    '''
    仓库信息的序列化，增，删，改
    '''

    class Meta:
        model = WarehouseModel
        fields = '__all__'


class WarehouseSearchhSerializer(serializers.ModelSerializer):
    '''
    仓库信息的序列化，查询
    '''
    # 查询结果的序列化, SlugRelatedField,返回主表的某一个字段值:slug_field可以指定一个需要展示的字段
    leader_user = serializers.SlugRelatedField(slug_field='real_name', read_only=True)

    class Meta:
        model = WarehouseModel
        fields = '__all__'
